<?php

namespace app\admin\controller\service\money;

use app\common\controller\Backend;
use think\Db;
/**
 * 会员支付
 *
 * @icon fa fa-circle-o
 */
class Pluspay extends Backend
{

    /**
     * Pluspay模型对象
     * @var \app\admin\model\service\money\Pluspay
     */
    protected $model = null;

    public function _initialize()
    {
        parent::_initialize();
        $this->model = new \app\admin\model\service\money\Pluspay;
        $this->view->assign("paytypeList", $this->model->getPaytypeList());
        $this->view->assign("isUpdateList", $this->model->getIsUpdateList());
        $this->view->assign("stateList", $this->model->getStateList());
    }


    public function index()
    {
        //设置过滤方法
        $this->request->filter(['strip_tags', 'trim']);
        if (false === $this->request->isAjax()) {
            return $this->view->fetch();
        }
        //如果发送的来源是 Selectpage，则转发到 Selectpage
        if ($this->request->request('keyField')) {
            return $this->selectpage();
        }
        [$where, $sort, $order, $offset, $limit] = $this->buildparams();
        $list = $this->model
            ->where($where)
            ->order($sort, $order)
            ->paginate($limit);
        foreach ($list as &$value)
        {
            $value->nickname = \app\admin\model\User::where('id',$value['user_id'])->value('nickname');
            $value->plusname = \app\admin\model\service\config\Plusconfig::where('id',$value['plus_id'])->value('name');
        }
        $result = ['total' => $list->total(), 'rows' => $list->items()];
        return json($result);
    }



}
